//
//  TableController.m
//  SoundWave
//
//  Created by 朱帅 on 2017/3/6.
//  Copyright © 2017年 Zs. All rights reserved.
//

#import "TableController.h"
#import "SoundWaveController.h"

@interface TableController () <UITableViewDelegate, UITableViewDataSource>

@end

@implementation TableController
{
    UITableView *_tableView;
    NSArray *_dataArr;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setData];
    [self setUI];
}

- (void)setData
{
    
    _dataArr = @[@"Queen - We Will Rock You",@"Justin Timberlake,Black Eyed Peas - Where Is The Love？",@"Pianoboy - The truth that you leave"];
}

- (void)setUI
{
    _tableView = [[UITableView alloc]initWithFrame:self.view.frame];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.textLabel.text = _dataArr[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SoundWaveController *vc = [[SoundWaveController alloc]init];
    vc.songName = _dataArr[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
